﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
//using System.Data.OleDb;

namespace SNPAD
{
    public partial class Frm_RPTTrack : Form
    {
        public Frm_RPTTrack()
        {
            InitializeComponent();
        }

        private void Frm_RPTTrack_Load(object sender, EventArgs e)
        {
            dateTimeInput2.Value = DateTime.Today;
            dateTimeInput1.Value = DateTime.Today;
        }


        private void button2_Click(object sender, EventArgs e)
        {


//            string values = @"select a.fan_code,a.create_time,a.ZC_Value ,b.model_code, m.Model_Desc, b.Pl_Code phPl_code,b.LowerG ,b.LowerQ,b.StaticG ,b.StaticQ ,b.UpperG,b.UpperQ ,
//b.test_time phTest_time, b.Judge phJudge, c.Pl_Code sdPl_code, c.sdValue ,c.judge sdJudge,
//  c.test_time sdTest_time,e.Pl_Code SVPl_Code,  e.awake_i,e.Current1 ,
//e.Current2,e.Current3,e.Cush_tach_H,e.Cush_tach_M,e.dfc_final,e.dfc_init,  e.Noise,e.Noise_M,
//e.P1_07_in_i,e.P1_02_hd,e.P1_07_lo,e.P1_07_oc,e.P1_08_hd,e.P1_1_v,e.P1_13_adc_oc,e.P1_13_adc_oc_1,e.P1_13_adc_oc_1,
//e.P1_13_adc_oc_2,e.P1_13_in_i,e.P1_13_oc,e.P1_2_lkg,e.P1_7_oc,e.P1_8_lkg,e.P1_9_v,e.PCB_Code,e.PCBA_sn,e.PCBA_ver
//, e.Speed1,e.Speed2 ,e.Speed3,e.System_VB_1,e.System_VB_2,e.Remeture,e.TGJudge,
// e.up_05_adc_off,e.up_05_adc_on,e.up_12_adc_off,e.up_12_adc_on,e.up_mon_adc,e.UUT_TEMP,
//e.vibX,e.vibY,e.VibZ,e.X_Vib_H,e.WaveJudge,e.Ver_sn,  e.V_Vib_H,e.judge svjudge  ,e.test_time SVTest_Time, d.pl_code bdpl_code, d.Barcode_2d ,d.judge bdJudge, d.test_time bdTest_time from JC_Fan a
//left join Ph_Balance b on a.Fan_Code = b.Fan_Code
//left join JC_Model m on b.Model_Code = m.Model_Code
//left join hv_sd c on a.Fan_Code = c.Fan_Code
//left join HV_BD d on a.Fan_Code = d.Fan_Code
//left join HV_SV e on d.Barcode_2d = e.Barcode_2d ";



            string values = @"select a.fan_code,a.create_time,a.ZC_Value ,  m.Model_Desc, b.Pl_Code phPl_code,b.LowerG ,b.LowerQ,b.StaticG ,b.StaticQ ,b.UpperG,b.UpperQ ,
b.test_time phTest_time, b.Judge phJudge, c.Pl_Code sdPl_code, c.sdValue ,c.judge sdJudge,
  c.test_time sdTest_time, e.*, d.pl_code bdpl_code ,d.judge bdJudge, d.test_time bdTest_time from JC_Fan a
left join Ph_Balance b on a.Fan_Code = b.Fan_Code
left join JC_Model m on b.Model_Code = m.Model_Code
left join hv_sd c on a.Fan_Code = c.Fan_Code
left join HV_BD d on a.Fan_Code = d.Fan_Code
left join HV_SV e on d.Barcode_2d = e.Barcode_2d ";

            values += " where a.stype='hv' and a.create_time between '" + dateTimeInput1.Value.ToString("yyyy-MM-dd") + "' and '" + dateTimeInput2.Value.AddDays(1).ToString("yyyy-MM-dd") + "'";
            if (txtFan_Code.Text.Trim().Length > 0)
            {
                values += " and a.fan_code='" + txtFan_Code.Text.Trim () + "'";
            }
            if (txtMB_Code.Text.Trim ().Trim().Length > 0)
            {
                values += " and d.barcode_2d='" + txtMB_Code.Text.Trim() + "'";
            }
            DataTable dt = OleDbHelper3.ExecuteDataTable(values);

            skinDataGridView3.DataSource = dt;

        }

        private void skinButton1_Click(object sender, EventArgs e)
        {
            //Excel.SaveAs(skinDataGridView3);

            Excel.ExportExcel("", skinDataGridView3);
        }
         

        private void cmbPL_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void skinDataGridView3_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }
    }
}
